package com.hmall.api.item;


import com.hmall.api.item.dto.ItemDTO;
import com.hmall.api.item.dto.OrderDetailDTO;
import com.hmall.api.item.fallback.ItemClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

/**
 *商品服务(服务提供者)的客户端接口类
 *
 * @Author mr.zhang
 * Date 2025/6/17 21:17
 */
@FeignClient(name = "item-service",path = "items",fallbackFactory = ItemClientFallbackFactory.class)//name的值为服务提供者的服务名
public interface ItemClient {

    /**
     * 批量查询商品
     * @param ids
     * @return
     */
    @GetMapping
    public List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids);

    /**
     * 扣除库存
     */
    @PutMapping("/stock/deduct")
    public void deductStock(@RequestBody List<OrderDetailDTO> items);


}
